import os
from docx import Document

infos =[
        ['00001', 2030, 12, 12, 12, 0, '闯红灯', 300],
        ['00002', 2032, 12, 12, 12, 0, '违反禁令', 300],
        ['00003', 2033, 12, 12, 12, 0, '违章停车', 300]
]

for info in infos:
    doc1 = Document('模板.docx')
    for p in doc1.paragraphs:
        for run in p.runs:
            run.text = run.text.replace('{0}', info[0])
            run.text = run.text.replace('{1}', str(info[1]))
            run.text = run.text.replace('{2}', str(info[2]))
            run.text = run.text.replace('{3}', str(info[3]))
            run.text = run.text.replace('{4}', str(info[4]))
            run.text = run.text.replace('{5}', str(info[5]))
            run.text = run.text.replace('{6}', info[6])
            run.text = run.text.replace('{7}', str(info[7]))
    if not os.path.exists('./create_data/生成word'):
        os.makedirs('./create_data/生成word'
)

    doc1.save(f'./create_data/生成word/车辆{info[0]}.docx')



